//
//  RDBottomSettingView.m
//  readApp
//
//  Created by 飞猪 on 2018/8/16.
//  Copyright © 2018年 😝😝😝😝😝. All rights reserved.
//

#import "RDBottomSettingView.h"

@implementation RDBottomSettingView

- (instancetype)initWithCoder:(NSCoder *)coder {
  self = [super initWithCoder:coder];
  if (self) {
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
    [self.dayOrNightBtn addGestureRecognizer:tap];
  }
  return self;
}

- (void)awakeFromNib {
  [super awakeFromNib];
  
  self.backgroundColor = UIColorHex(333333);
  self.bgView.backgroundColor = self.backgroundColor;
  
  UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
  [self.dayOrNightBtn addGestureRecognizer:tap];
  
  // 设置thumb normal时的图片
  UIImage *thumbImageNormal = [UIImage imageNamed:@"slider_Dot"];
  
  [self.slider setThumbImage:thumbImageNormal forState:UIControlStateNormal];
  self.slider.minimumTrackTintColor = UIColorHex(A35046);
  [self.slider setMaxFractionDigitsDisplayed:0];
  self.slider.popUpViewColor = UIColorHex(333333); //UIColorHex(A35046);
  self.slider.font = [UIFont fontWithName:@"Menlo-Bold" size:22];
//  self.slider.textColor = [UIColor colorWithHue:0.55 saturation:1.0 brightness:0.5 alpha:1];
}

- (void)tap:(UITapGestureRecognizer *)ges {
  if (self.delegate && [self.delegate respondsToSelector:@selector(bottomSettingView:clickedIndex:)]) {
    
    BOOL res = [self.centerTitle.text isEqualToString:@"夜间"];
    if (res) {
      self.centerTitle.text = @"日间";
      self.centerImg.image = [UIImage imageNamed:@"day"];
    }
    else {
      self.centerTitle.text = @"夜间";
      self.centerImg.image = [UIImage imageNamed:@"night"];
    }
    
    [self.delegate bottomSettingView:self clickedIndex:BottomSettingClickTypeDayOrNight];
  }
}

- (IBAction)category:(UIButton *)sender {
  
  if (self.delegate && [self.delegate respondsToSelector:@selector(bottomSettingView:clickedIndex:)]) {
    [self.delegate bottomSettingView:self clickedIndex:BottomSettingClickTypeCatalogue];
  }
  
}

- (IBAction)preCh:(UIButton *)sender {
  if (self.delegate && [self.delegate respondsToSelector:@selector(bottomSettingView:clickedIndex:)]) {
    [self.delegate bottomSettingView:self clickedIndex:BottomSettingClickTypePreChapter];
  }
}

- (IBAction)nextCh:(UIButton *)sender {
  if (self.delegate && [self.delegate respondsToSelector:@selector(bottomSettingView:clickedIndex:)]) {
    [self.delegate bottomSettingView:self clickedIndex:BottomSettingClickTypeNextChapter];
  }
}

- (IBAction)settingBtnClicked:(UIButton *)sender {
  if (self.delegate && [self.delegate respondsToSelector:@selector(bottomSettingView:clickedIndex:)]) {
    [self.delegate bottomSettingView:self clickedIndex:BottomSettingClickTypeSetting];
  }
}

@end
